class MessageModel {
  // 基本属性
  late Long? messageId;
  late Long? userId;
  late Long? deviceId;
  late String? messageName;
  late String? messageContent;
  late int? deviceType;
  late int? alarmType;
  late int? messageType;
  late int? messageStatus;
  late int? isRead;        // 是否已读（0-否，1-是）
  late int? isOrder;       // 是否其他
  late String? brief;      // 备份
  late String? readTime;   // 读取时间
  late int? del;           // 逻辑删除

  // 继承BaseEntity的属性（假设BaseEntity包含createTime和updateTime）
  final String? thisTime;
  final String? updateTime;
  final String? createTimeData;

  MessageModel({
    this.messageId,
    this.userId,
    this.deviceId,
    this.messageName,
    this.messageContent,
    this.deviceType,
    this.alarmType,
    this.messageType,
    this.messageStatus,
    this.isRead,
    this.isOrder,
    this.brief,
    this.readTime,
    this.del,
    this.thisTime,
    this.updateTime,
    this.createTimeData,
  });

  // 从JSON数据创建Message实例的工厂方法
  factory MessageModel.fromJson(Map<String, dynamic> json) {
    return MessageModel(
      messageId: json['messageId'] as Long?,
      userId: json['userId'] as Long?,
      deviceId: json['deviceId'] as Long?,
      messageName: json['messageName'] as String?,
      messageContent: json['messageContent'] as String?,
      deviceType: json['deviceType'] as int?,
      alarmType: json['alarmType'] as int?,
      messageType: json['messageType'] as int?,
      messageStatus: json['messageStatus'] as int?,
      isRead: json['isRead'] as int?,
      isOrder: json['isOrder'] as int?,
      brief: json['brief'] as String?,
      readTime: json['readTime'] as String?,
      del: json['del'] as int?,
      thisTime: json['thisTime'] as String?,
      updateTime: json['updateTime'] as String?,
      createTimeData: json['createTimeData'] as String?,
    );
  }

  // 将Message实例转换为JSON格式
  Map<String, dynamic> toJson() {
    return {
      'messageId': messageId,
      'userId': userId,
      'deviceId': deviceId,
      'messageName': messageName,
      'messageContent': messageContent,
      'deviceType': deviceType,
      'alarmType': alarmType,
      'messageType': messageType,
      'messageStatus': messageStatus,
      'isRead': isRead,
      'isOrder': isOrder,
      'brief': brief,
      'readTime': readTime,
      'del': del,
      'thisTime': thisTime,
      'updateTime': updateTime,
      'createTimeData': createTimeData,
    };
  }

  @override
  String toString() {
    return 'MessageModel{'
        'messageId: $messageId, '
        'userId: $userId, '
        'deviceId: $deviceId, '
        'messageName: $messageName, '
        'messageContent: $messageContent, '
        'deviceType: $deviceType, '
        'alarmType: $alarmType, '
        'messageType: $messageType, '
        'messageStatus: $messageStatus, '
        'isRead: $isRead, '
        'isOrder: $isOrder, '
        'brief: $brief, '
        'readTime: $readTime, '
        'del: $del, '
        'thisTime: $thisTime, '
        'updateTime: $updateTime'
        'createTimeData: $createTimeData'
        '}';
  }
}

// 为了兼容Dart中没有Long类型的问题，定义Long类型别名
typedef Long = int;